﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="com.huigo.B2B.Web.Login" %>

<%@ Register Src="/ctrl/header.ascx" TagName="header" TagPrefix="header" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>用户登录</title>

    <script src="/js/jquery.js" type="text/javascript"></script>

    <link href="/css/auto.css" rel="stylesheet" type="text/css" />
    <link href="/css/bootstrap.css" rel="stylesheet" />
    <style type="text/css">
        body
        {
            padding-top: 60px;
            padding-bottom: 40px;
        }
    </style>
    <link href="/css/bootstrap-responsive.css" rel="stylesheet" />

    <script type="text/javascript">
        function getBytesLength(str) {
            return str.replace(/[^\x00-\xff]/g, 'xx').length;
        };
        function checkLogin() {
            $("#loginname_error").text("");
            $("#loginpwd_error").text("");
            var loginname = $("#loginname").val();
            var loginpwd = $("#loginpwd").val();
            if ($("#rememberpsw").attr("checked") == true) {
                $("#rememberpsw").val("true");
            }
            var usern = /^[A-Za-z0-9_-]|[A-Za-z0-9\u4e00-\u9fa5]|[\u4e00-\u9fa5_-]+$/;
            var pwd = /^[A-Za-z0-9_-]+$/;
            var email = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
            if (loginname != "" && loginpwd != "") {
                if (!RegExp(email).test(loginname)) {
                    if (!RegExp(usern).test(loginname) || (getBytesLength(loginname) < 4 || getBytesLength(loginname) > 20)) {
                        $("#loginname_error").text("由4-12位中文、英文、数字及“_”、“-”组成");
                        return false;
                    }
                }
                if (!RegExp(pwd).test(loginpwd) || (loginpwd.length < 6 || loginpwd.length > 20)) {
                    $("#loginpwd_error").text("6-20位字符，由英文、数字及“_”、“-”组成");
                    return false;
                }
                else {
                    $("#loginname_error").text("");
                    $("#loginpwd_error").text("");
                    return true;
                }
            }
            else {
                if (loginname == "") {
                    $("#loginname_error").text("对不起，用户名不能为空！");
                }
                else if (!RegExp(email).test(loginname)) {
                    if (!RegExp(usern).test(loginname) || (getBytesLength(loginname) < 4 || getBytesLength(loginname) > 12)) {
                        $("#loginname_error").text("由4-12位中文、英文、数字及“_”、“-”组成");
                    }
                }
                else {
                    $("#loginname_error").text("");
                }
                if (loginpwd == "") {
                    $("#loginpwd_error").text("对不起，密码不能为空！");
                }
                else if (!RegExp(pwd).test(loginpwd) || (loginpwd.length < 6 || loginpwd.length > 20)) {
                    $("#loginpwd_error").text("6-20位字符，由英文、数字及“_”、“-”组成");
                }
                else {
                    $("#loginpwd_error").text("");
                }
                return false;
            }
        }      
    </script>

</head>
<body>
    <header:header id="head" runat="server">
    </header:header>
    <div class="container">
        <div class="span12">
            <h1 style="text-align: center;">
                用户登录</h1>
        </div>
        <form id="form1" runat="server" action="Login.aspx" method="post">
        <div class="row-fluid" style="text-align: center;">
            <div class="span12">
                <div>
                    <div class="field">
                        <div>
                            用户名&nbsp;<input id="loginname" name="loginname" type="text" class="txt-input" maxlength="50"
                                tabindex="1" value="" />
                        </div>
                        <div>
                            <span id="loginname_error" class="error"></span>
                        </div>
                    </div>
                    <div class="field">
                        <div>
                            密&nbsp;&nbsp;码&nbsp;<input id="loginpwd" name="loginpwd" type="password" class="txt-input" tabindex="2"
                                value="" />
                        </div>
                        <div>
                            <span id="loginpwd_error" class="error"></span>
                        </div>
                    </div>
                    <div class="field rememberpsw">
                        <div>
                            <input style="margin-right: 10px;" name="isRemember" type="checkbox" value="" id="rememberpsw"
                                class="checkbox" />记住账号</div>
                    </div>
                    <div class="field">
                        <div>
                            <input name="isLogin" value="true" type="hidden" />
                            <input name="backUrl" type="hidden" value="/login.aspx" />
                            <input name="toUrl" id="toUrl" type="hidden" value="<%=toUrl %>" />
                            <input type="submit" name="button" id="loginsubmit" onclick=" return checkLogin();"
                                value="&nbsp;&nbsp;&nbsp;&nbsp;立即登录&nbsp;&nbsp;&nbsp;&nbsp;" class="button btn-big btn-orange" /></div>
                        <div class="field">
                            <div>
                                还不是会员？ 现在就 <a href="Register.aspx">注册</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>

    <script src="/js/bootstrap-collapse.js"></script>

</body>
</html>
